The present invention generally relates to computer graphics display systems and, more particularly, to a method and apparatus for performing H-space Bump Mapping that is suitable for implementation with H-space lighting, previously developed by HP-Labs, in a fragment processor of a graphics pipeline of a computer graphics display system.
Computer graphics display systems are commonly used for displaying graphical representations of objects on a two-dimensional video display screen. Current computer graphics display systems provide highly detailed representations and are used in a variety of applications. A computer graphics display system generally comprises a central processing unit (CPU), system memory, a graphics system and a graphics display screen.
In typical computer graphics display systems, an object to be presented on the display screen is broken down into graphics primitives. Primitives are basic components of a graphics display and may include points, lines, vectors and polygons (e.g., triangles and quadrilaterals). Typically, a hardware/software scheme is implemented to render, or draw, the graphics primitives that represent a view of one or more objects being represented on the display screen.
Generally, the primitives of the three-dimensional object to be rendered are generated in terms of primitive data by software being executed by the host CPU. For example, when the primitive is a triangle, the software being executed by the host computer defines the primitive in terms of the X, Y and Z coordinates of its vertices, the normals of the vertices, Nx, Ny and Nz, and the red, green. blue and alpha (R, G. B and xcex1) color values of each vertex. Alpha is a transparency value. Additional primitive data may be used in specific applications. Rendering hardware interpolates all of this data to compute the display screen pixels that represent each primitive, and the R, G, B and xcex1 values for each pixel.
The graphics system is typically implemented in hardware and generally includes a geometry accelerator, a rasterizer, a frame buffer controller and a frame buffer memory. The graphics system typically also includes texture mapping hardware. In cases where the graphics system comprises a geometry accelerator, the geometry accelerator receives vertex data from the host CPU that defines the primitives that make up the view to be displayed. Many of the tasks performed by the graphics accelerator in hardware may instead be performed in software being executed on the host CPU. However, in many cases, the graphics accelerator is preferred because it is normally capable of performing these tasks faster than the host computer, thus increasing the overall rendering speed of the computer graphics display system.
The geometry accelerator typically comprises a transform component, which receives vertex data from the host CPU, a clipping component, an illumination component, and a plane equations component. The transform component performs transformations on the vertex data received from the CPU, such as rotation and translation of the image space defined by vertex data. The clipping component clips the vertex data so that only vertex data relating to primitives that make up the portion of the view that will be seen by the user is retained for further processing. The illumination component calculates the final colors of the vertices of the primitives based on the vertex data and based on lighting conditions. The plane equations component generates floating point equations that define the image space within the vertices. The floating point equations are later converted into fixed point equations by a floating point-to-fixed point component. A rasterizer, which is generally viewed as being external to the graphics accelerator, receives the output of the plane equations component of the graphics accelerator. The rasterizer generally interpolates the values of the pixels within the interior of each primitive defined by the vertices output from the geometry accelerator.
A fragment processor component receives the output of the rasterizer and generates the final screen coordinate and color data for each pixel in each primitive. The fragment processor comprises a texture mapping component, which performs texture mapping, and a fragment lighting component, which computes the actual values of each of the pixels within each of the primitives. This is to be distinguished from the process performed by the rasterizer of interpolating the pixel values of the primitives. The aforementioned technique known as H-space lighting may be used by the fragment lighting component to perform lighting of the scene. H-space lighting is a less computationally expensive technique for achieving effects that are generally equivalent to the effects achieved by a well-known lighting technique generally referred to as Phong lighting. Both of these techniques are algorithms that perform lighting on a per-pixel basis for an entire scene.
It is known to have the fragment lighting component also perform a technique known as bump mapping in conjunction with the Phong lighting technique. Bump mapping is a technique that provides lighting effects that show the texture of the surface in such a way that the light and dark areas on the surface generated by the lighting will change in accordance with changes in the positioning of the light source in the scene. Utilizing bump mapping with Phong lighting further increases the computational overhead associated with the functions performed by the fragment lighting component of the fragment processor, which affects the overall rendering speed of the computer graphics display system.
Since H-space lighting is less computationally expensive than Phong lighting, it would be advantageous to provide a bump mapping technique that can be used in conjunction with H-space lighting and that is less computationally expensive than the bump mapping technique utilized with the Phong lighting technique. Accordingly, a need exists for a method and apparatus that utilize a computationally inexpensive bump mapping technique in conjunction with H-space lighting in order to maximize the speed with which the computations of the fragment processor can be performed, thereby increasing the overall processing speed of the computer graphics display system.
The present invention provides a method and apparatus for performing H-space bump mapping. The apparatus of the present invention is a fragment processor of a computer graphics display system. The method of the present invention is performed by the fragment processor. In accordance with the method of the present invention, for each vertex of each polygon being processed, the fragment processor calculates both diffuse and specular lighting terms. Then, for each fragment within the polygon defined by the vertices, the fragment processor interpolates the specular and diffuse lighting terms to obtain diffuse and specular lighting terms for each fragment. If bump mapping has been enabled, the fragment processor adds perturbations to the interpolated diffuse and specular lighting terms to generate the bump mapping for each fragment. The color of each fragment is then determined using information relating to the bump mapped image.
In accordance with the preferred embodiment of the present invention, prior to performing the H-space bump mapping algorithm, texture coordinate gradient vectors are calculated for the image to be rendered. During the H-space bump mapping algorithm of the present invention, the H-space reference vectors are aligned with the texture coordinate gradient vectors. The specular and diffuse lighting terms are calculated using the H-space reference vectors. Since the H-space reference vectors are aligned with the texture coordinate gradient vectors, it is not necessary to transform the specular and diffuse lighting terms into the coordinate system associated with the texture coordinates of the bump map on a per fragment (i.e., per pixel basis). Once the H-space reference vectors have been aligned with the texture coordinate gradient vectors, the algorithm proceeds in the aforementioned manner.
These and other features and advantages of the present invention will become apparent to those skilled in the art from the following discussion, figures and claims.